<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增文件')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-files-add" enctype="multipart/form-data">
            <div class="form-group">
                <label class="col-sm-3 control-label">文件名称：</label>
                <div class="col-sm-8">
                    <input name="filename" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">选择文件：</label>
                <div class="col-sm-8">
                    <input name="files" id="fileContent" class="form-control file-upload" type="file" multiple required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/files";

        $("#form-files-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var formData = new FormData($("#form-files-add")[0]);
                $.ajax({
                    type: "POST",
                    url: prefix + "/batchAdd",
                    data: formData,
                    contentType: false,
                    processData: false,
                    success: function(result) {
                        if (result.code == web_status.SUCCESS) {
                            $.modal.alertSuccess("操作成功");
                            $.modal.close();
                            $.table.refresh();
                        } else {
                            $.modal.alertError(result.msg);
                        }
                    }
                });
            }
        }

        $(".file-upload").fileinput({
            showUpload: false,
            showCaption: true,
            browseClass: "btn btn-primary",
            maxFileCount: 20,
            autoReplace: false,
            msgFilesTooMany: "选择的文件数量超过限制！"
        });
    </script>
</body>
</html> 